﻿using System;
#if NETFX_CORE
using Windows.Foundation;
using Windows.Storage.Streams;
#else
using System.IO;
using System.Threading.Tasks;
using System.Threading;
#endif

namespace Microsoft.Media.IngestClient
{
    /// <summary>
    /// Represents a class that can stream the output from PushClient to a destination of it's choosing. E.g. the web or file system.
    /// </summary>
    public interface IPushOutputConsumer
    {
#if NETFX_CORE
        /// <summary>
        /// Called once to send a continuously growing stream.
        /// </summary>
        /// <param name="inputStream">The stream containing the data to send. Data will be added to the stream as time goes on.</param>
        /// <returns>An awaitable action with a progress callback that indicates how many bytes have been successfully consumed.</returns>
        IAsyncActionWithProgress<ulong> SendDataAsync(IInputStream inputStream);

        /// <summary>
        /// Provides notification that the session is done sending information.
        /// </summary>
        /// <returns>An awaitable action that returns when all data has been consumed.</returns>
        IAsyncAction TerminateAsync();
#else
        /// <summary>
        /// Called once to send a continuously growing stream.
        /// </summary>
        /// <param name="inputStream">The stream containing the data to send. Data will be added to the stream as time goes on.</param>
        /// <param name="cancellationToken">A cancellation token used to terminate the async action.</param>
        /// <param name="progress">An object that receives notification of how many bytes have been successfully consumed.</param>
        /// <returns>An awaitable action that returns when TerminateAsync has been called and all data currently in the stream has been consumed.</returns>
        Task SendDataAsync(Stream inputStream, CancellationToken cancellationToken, IProgress<ulong> progress);
        
        /// <summary>
        /// Provides notification that the session is done sending information.
        /// </summary>
        /// <returns>An awaitable action that returns when all data has been consumed.</returns>
        Task TerminateAsync();
#endif
    }
}
